package com.farm.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

@Data
@NoArgsConstructor
public class PolicyEs {
    private Long id;

    // 自动补全字段
    private String title;

    private Long userId;

    private String description;

    // 自动补全字段
    private String place;

    private String content;

    private Integer state;
    private String label;

    private LocalDateTime createTime;


    private LocalDateTime updateTime;
    private List<String> suggestion;
    public PolicyEs(Policy policy){
        this.id = policy.getId();
        this.title = policy.getTitle();
        this.userId = policy.getUserId();
        this.description = policy.getDescription();
        this.place = policy.getPlace();
        this.content = policy.getContent();
        this.state = policy.getState();
        this.label = policy.getLabel();
        this.createTime = policy.getCreateTime();
        this.updateTime = policy.getUpdateTime();

        // 组装suggestion字段用于自动补全
        this.suggestion = Arrays.asList(this.place, this.title, this.label);
    }
}
